package com.zhiyou100.service.impl;

import com.zhiyou100.mapper.UserMapper;
import com.zhiyou100.pojo.User;
import com.zhiyou100.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@SuppressWarnings("restriction")
@Service
public class UserServiceImpl implements UserService{
	@Resource
	private UserMapper um;

	public List<User> list(Integer start, Integer pageSize) {
		//list 用户的信息，角色的信息，权限的信息
		Map<String,Integer> map=new HashMap<String, Integer>();
		map.put("start",start);
		map.put("pageSize",pageSize);
		List<User> users= um.list(map);
		return users;
	}

    public Long findAllCount() {
        return um.findAllCount();
    }

    public Long countPage(Integer pageSize) {
	    //总页数
        long count=um.findAllCount();
        long countPage=0;
        if (count%pageSize==0){
            countPage=count/pageSize;
        }else {
            countPage=count/pageSize+1;
        }
        return countPage;
    }
}
